import { changePrimary } from '@/hooks/useTheme'
import { defineStore } from 'pinia'
import type { GlobalConfig } from '@/types/globalConfig'

export const globalConfigStore = defineStore('globalConfig', {
  persist: true,
  state: (): GlobalConfig => {
    return {
      componentSize: 'default',
      primary: '#409eff',
      isDark: false,
      breadcrumb: true,
      tabs: false,
      footer: false,
    }
  },
  actions: {
    async setTheme() {
      const { useDark, changePrimary } = await import('@/hooks/useTheme')
      this.isDark ? useDark() : ''
      changePrimary(this.primary)
    },
  },
})
